<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src=".././static/js/public-head.js"></script>
    <meta charset="UTF-8">
    <title>测试echart</title>
</head>
<body>
    <div id="echart-form"></div>
<div class="layui-hide"></div>
    <div id="main" style="width: 50%;height: 50%"></div>
</body>
</html>
<script src="../jsPlugin/ObjTree.js"></script>
<script src="echarts.min.js"></script>
<script type="text/javascript">
    layui.config({
        base: basePath+'/layui/lay/modules/'
    }).extend({
        //formSelects: 'formSelects-v4'
    }).use([ 'form', 'code' ], function() {
        var $ = layui.$
        var xotree = new XML.ObjTree();
        var form = layui.form

        var myChart = echarts.init(document.getElementById('main'));

        $.post(basePath+"/echartsResource/model/echart-line.xml", function (rst) {
            var xmlDom = $(rst).find("formNode")
            console.log(xmlDom.html())
            $("#echart-form").html(xmlDom.html())
            $(".layui-hide").text($(rst).find("tempOption").text())
            form.render()

            form.on("submit(echart-line-form-bt)", function (obj) {
                var field = obj.field
                field.tempOption = $(".layui-hide").text()
                field.formNode = xmlDom.html()

                $.post(basePath+"/echartTest",field,function(rst){
                    myChart.setOption(rst)
                },"json")
                return false
            })

        },"text")



        $.post(basePath+"/echartTest/index2",function(rst){
             $("#echart-form").html(rst.formNode)

             myChart.setOption(rst.option)


            $("input[name=test]").val(rst.formValue.test)
            $("select[name=series_data_type]").val(rst.formValue.series_data_type)
            form.render()
        },"json")
    })
</script>